import axios from '@/utils/request'

import { IPageResult } from './types/base'
import { IAddClaimType, IClaimType, IUpdateClaimType } from './types/claimTypes'

// 获取声明类型
export function pagedClaimTypes(currentPage = 1, take = 10, filter = '') {
  return axios<IPageResult<IClaimType>>({
    url: '/api/identity/claim-types',
    method: 'get',
    params: {
      skipCount: take * (currentPage - 1),
      maxResultCount: take,
      filter,
    },
  })
}

// 新增声明类型
export function addClaimType(data: IAddClaimType) {
  return axios({
    url: '/api/identity/claim-types',
    method: 'post',
    data,
  })
}

// 删除声明类型
export function deleteClaimType(claimTypeId: string) {
  return axios({
    url: `/api/identity/claim-types/${claimTypeId}`,
    method: 'delete',
  })
}

// 获取声明类型详情
export function getClaimType(id: string) {
  return axios<IClaimType>({
    url: `/api/identity/claim-types/${id}`,
    method: 'get',
  })
}
// 修改声明类型
export function updateClaimType(id: string, data: IUpdateClaimType) {
  return axios({
    url: `/api/identity/claim-types/${id}`,
    method: 'put',
    data,
  })
}
